//package com.example.demo.config.handler;
//
//import com.quartz.demo.annotation.SensitiveField;
//import com.quartz.demo.service.EncryptService;
//import com.quartz.demo.utils.AESUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//import java.lang.reflect.Field;
//import java.util.Objects;
//
//@Component
//public class AesEncryptServiceImpl implements EncryptService {
//
//  private AESUtils aesUtils;
//
//  @Value("${aes.key}")
//  private String key;
//
//  @Autowired
//  public AesEncryptServiceImpl(AESUtils aesUtils) {
//    this.aesUtils = aesUtils;
//  }
//
//  @Override
//  public <T> T encrypt(Field[] declaredFields, T paramsObject) throws Exception {
//    for (Field field : declaredFields) {
//      //取出所有被EncryptDecryptField注解的字段
//      SensitiveField sensitiveField = field.getAnnotation(SensitiveField.class);
//      if (!Objects.isNull(sensitiveField)) {
//        field.setAccessible(true);
//        Object object = field.get(paramsObject);
//        //暂时只实现String类型的加密
//        if (object instanceof String) {
//          String value = (String) object;
//          //加密  这里我使用自定义的AES加密工具
//          field.set(paramsObject, aesUtils.aesEncrypt(value,key));
//        }
//      }
//    }
//    return paramsObject;
//  }
//}